﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="apple-mobile-web-app-title" content="思路广惠">
		<title>卡号管理</title>

		<meta content="telephone=no" name="format-detection" />

		<link rel="stylesheet" type="text/css" href="../../src/css/base.css?1.0" />
	</head>

	<body class="body-bg">
		<header class="header">
			<a href="javascript: history.back(-1)" class="head-le"><i class="iconfont icon-fanhui i2m"></i></a>
			<h1 class="header-txt">新增银行卡</h1>
		</header>
		<section class="top1rem">
			<ul class="setup-u">
				<li class="pad1rem setup-btm flexs-bw">
					<select class="address-sel" id="banksel">
						<option value="0"> 请选择银行账户 </option>
					</select>
					<i class="iconfont icon-gengduo"></i>
				</li>
				<li class="address-inp setup-btm"><span>银行卡卡号：</span> <input type="text" class="bankcard addRess " /> </li>
				<li class="address-inp setup-btm"><span>开户人姓名：</span> <input type="text" class="bankcard addRess " /> </li>
				<li class="address-inp"><span>开户行地址：</span> <input type="text" class="bankcard addRess " /> </li>
			</ul>

			<div class="setup-u top1rem address-inp flexs-bw">
				<span> 设为默认 </span>
				<input class="mui-switch" type="checkbox" checked="">
			</div>

			<div class="own-save">
				<button class="own-save-btn" id="banksave" type="button">
                确认
            </button>
			</div>

		</section>
		<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script src="//cdn.bootcss.com/layer/3.0.1/mobile/layer.js"></script>
		<script src="../../src/js/all.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			// 获得银行信息
			$.get(urls + "/BaseSelect/GetBank", function(res) {
				if(res.Return_ID == 0) {
					var seltxt = "";
					for(var i = 0; i < res.Return_Data.length; i++) {
						seltxt += '<option value=' + res.Return_Data[i].Value + '>' + res.Return_Data[i].Text + '</option>';
					}
					$("#banksel").append(seltxt);
				}
			});

			$(document).on("click", "#banksave", function() {
				var bankcard = $(".bankcard");
				var layers = function(txt, callback) {
					layer.open({
						content: txt,
						skin: 'msg',
						time: 2,
						end: callback
					});
				};
				if($("#banksel").val() == 0) {
					layers("请选择银行账户");
				} else if(/^\d{14}$/.test(bankcard.eq(0).val()) == false) {
					layers("银行卡号为14位纯数字");
				} else if(bankcard.eq(1).val() == "") {
					layers("开户人姓名不能为空");
				} else if(bankcard.eq(2).val() == "") {
					layers("开户行地址不能为空");
				} else {
					var datas = {
						MembersID: MembersID,
						BankID: $("#banksel").val(),
						Holder: bankcard.eq(1).val(),
						Account: bankcard.eq(0).val(),
						Address: bankcard.eq(2).val(),
						Mark: $("input[type=checkbox]").is(":checked") ? 1 : 0
					};
					console.log(datas)
					$.post(urls + "/WorkMembersBank/V1.0/AddMembersBank", datas, function(res) {
						layers(res.Return_Mess);

					});
				}
			});
		</script>
	</body>

</html>